<!DOCTYPE html>
<html>
<head>
    

    

    



    <meta charset="utf-8">
    
    
    
    
    <title>CSS_Animation进阶 | SongKaBaKa</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="">
    <meta name="description" content="Animation笼统来讲，帧动画就是定义几个帧的动作，编成一组起个名字，最后让某个元素调用即可 关键帧使用介绍12345678@keyframes name1&amp;#123;	from&amp;#123;		动作	&amp;#125;	to&amp;#123;		动作	&amp;#125;&amp;#125;  在元素中使用 12animation-name：name1；&#x2F;&#x2F;调用我们的动画animation-durat">
<meta property="og:type" content="article">
<meta property="og:title" content="CSS_Animation进阶">
<meta property="og:url" content="https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/index.html">
<meta property="og:site_name" content="SongKaBaKa">
<meta property="og:description" content="Animation笼统来讲，帧动画就是定义几个帧的动作，编成一组起个名字，最后让某个元素调用即可 关键帧使用介绍12345678@keyframes name1&amp;#123;	from&amp;#123;		动作	&amp;#125;	to&amp;#123;		动作	&amp;#125;&amp;#125;  在元素中使用 12animation-name：name1；&#x2F;&#x2F;调用我们的动画animation-durat">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2020-09-26T08:12:44.681Z">
<meta property="article:modified_time" content="2020-10-04T09:05:41.699Z">
<meta property="article:author" content="Song Wani">
<meta name="twitter:card" content="summary">
    
    <link rel="shortcut icon" href="/blog/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

<meta name="generator" content="Hexo 4.2.1"></head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/blog/img/brand.jpg)">
      <div class="brand">
        <a href="/blog/" class="avatar waves-effect waves-circle waves-light">
          <img src="/blog/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">Song Wani</h5>
          <a href="mailto:bugsong@wo.cn" title="bugsong@wo.cn" class="mail">bugsong@wo.cn</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/blog/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/blog/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                Archives
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/blog/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                Tags
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/blog/categories"  >
                <i class="icon icon-lg icon-th-list"></i>
                Categories
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://songbug.gitee.io/blog" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">CSS_Animation进阶</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="Search">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">CSS_Animation进阶</h1>
        <h5 class="subtitle">
            
                <time datetime="2020-09-26T08:12:44.681Z" itemprop="datePublished" class="page-time">
  2020-09-26
</time>


            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#Animation"><span class="post-toc-number">1.</span> <span class="post-toc-text">Animation</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#关键帧使用介绍"><span class="post-toc-number">1.1.</span> <span class="post-toc-text">关键帧使用介绍</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#帧顺序与起始与终点帧的特性"><span class="post-toc-number">1.2.</span> <span class="post-toc-text">帧顺序与起始与终点帧的特性</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#移动的小方块"><span class="post-toc-number">1.3.</span> <span class="post-toc-text">移动的小方块</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#同时声明关键帧"><span class="post-toc-number">1.4.</span> <span class="post-toc-text">同时声明关键帧</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#同一元素应用多个动画与时间配置"><span class="post-toc-number">1.5.</span> <span class="post-toc-text">同一元素应用多个动画与时间配置</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#属性的重叠"><span class="post-toc-number">1.6.</span> <span class="post-toc-text">属性的重叠</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#多动画控制移动端引导背景页"><span class="post-toc-number">1.7.</span> <span class="post-toc-text">多动画控制移动端引导背景页</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#动画属性中间值讲解"><span class="post-toc-number">1.8.</span> <span class="post-toc-text">动画属性中间值讲解</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#动画执行的次数"><span class="post-toc-number">1.9.</span> <span class="post-toc-text">动画执行的次数</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#跳动的心案例"><span class="post-toc-number">1.10.</span> <span class="post-toc-text">跳动的心案例</span></a></li></ol></li></ol>
        </nav>
    </aside>


<article id="post-CSS_Animation进阶"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">CSS_Animation进阶</h1>
        <div class="post-meta">
            <time class="post-time" title="2020-09-26 16:12:44" datetime="2020-09-26T08:12:44.681Z"  itemprop="datePublished">2020-09-26</time>

            


            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h2 id="Animation"><a href="#Animation" class="headerlink" title="Animation"></a>Animation</h2><p>笼统来讲，帧动画就是定义几个帧的动作，编成一组起个名字，最后让某个元素调用即可</p>
<h3 id="关键帧使用介绍"><a href="#关键帧使用介绍" class="headerlink" title="关键帧使用介绍"></a>关键帧使用介绍</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">@keyframes name1&#123;</span><br><span class="line">	from&#123;</span><br><span class="line">		动作</span><br><span class="line">	&#125;</span><br><span class="line">	to&#123;</span><br><span class="line">		动作</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>在元素中使用</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">animation-name：name1；&#x2F;&#x2F;调用我们的动画</span><br><span class="line">animation-duration：2s；&#x2F;&#x2F;设定动画持续时间</span><br></pre></td></tr></table></figure>

<h3 id="帧顺序与起始与终点帧的特性"><a href="#帧顺序与起始与终点帧的特性" class="headerlink" title="帧顺序与起始与终点帧的特性"></a>帧顺序与起始与终点帧的特性</h3><p>可以使用0%来设置每个帧的动作，他们的顺序无关紧要，依旧会按照%进度来实现。</p>
<p><strong>只提供终点帧，起点帧是元素的默认状态</strong></p>
<p><strong>只提供起点帧，终点帧是元素的默认状态</strong></p>
<p>使用到延迟的话，这些帧都是过程帧。</p>
<h3 id="移动的小方块"><a href="#移动的小方块" class="headerlink" title="移动的小方块"></a>移动的小方块</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"utf-8"</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">title</span>&gt;</span><span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">style</span> <span class="attr">type</span>=<span class="string">"text/css"</span>&gt;</span></span><br><span class="line">			body &#123;</span><br><span class="line">				background-color: darkslateblue;</span><br><span class="line"><span class="css">				<span class="comment">/* 下面是将子盒子居中的语法 */</span></span></span><br><span class="line"><span class="css">				<span class="comment">/* display: flex; */</span></span></span><br><span class="line"><span class="css">				<span class="comment">/* justify-content: center; */</span></span></span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line"><span class="css">			<span class="selector-class">.father</span> &#123;</span></span><br><span class="line">				width: 400px;</span><br><span class="line">				height: 400px;</span><br><span class="line"><span class="css">				<span class="selector-tag">border</span>: <span class="selector-tag">solid</span> 1<span class="selector-tag">px</span> <span class="selector-id">#ddd</span>;</span></span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line"><span class="css">			<span class="selector-class">.main</span> &#123;</span></span><br><span class="line">				width: 100px;</span><br><span class="line">				height: 100px;</span><br><span class="line"><span class="css">				<span class="selector-tag">background</span>: <span class="selector-id">#7FFF00</span>;</span></span><br><span class="line">				animation-name: rounds;</span><br><span class="line">				animation: rounds 5s;</span><br><span class="line">				animation-timing-function: linear;</span><br><span class="line">				animation-iteration-count: infinite;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line"><span class="css">			<span class="keyword">@keyframes</span> rounds &#123;</span></span><br><span class="line">				25% &#123;</span><br><span class="line">					transform: translateX(300px);</span><br><span class="line">					background: green;</span><br><span class="line">				&#125;</span><br><span class="line">				25%,75%&#123;</span><br><span class="line"><span class="css">					<span class="comment">/* 这一句同时应用在了两个地方！ */</span></span></span><br><span class="line">					border-radius: 50%;</span><br><span class="line">				&#125;</span><br><span class="line"></span><br><span class="line">				50% &#123;</span><br><span class="line">					transform: translate(300px, 300px);</span><br><span class="line">					background: blue;</span><br><span class="line">					border-radius: 0%;</span><br><span class="line">				&#125;</span><br><span class="line"></span><br><span class="line">				75% &#123;</span><br><span class="line">					transform: translateY(300px);</span><br><span class="line">					background: red;</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">		<span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"father"</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"main"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h3 id="同时声明关键帧"><a href="#同时声明关键帧" class="headerlink" title="同时声明关键帧"></a>同时声明关键帧</h3><p>组合书写的理解，就是在运行到这个帧的时候，执行相同的动作，并不会覆盖原来的东西</p>
<h3 id="同一元素应用多个动画与时间配置"><a href="#同一元素应用多个动画与时间配置" class="headerlink" title="同一元素应用多个动画与时间配置"></a>同一元素应用多个动画与时间配置</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"utf-8"</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">title</span>&gt;</span><span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">style</span> <span class="attr">type</span>=<span class="string">"text/css"</span>&gt;</span></span><br><span class="line">			body &#123;</span><br><span class="line">				background-color: darkslateblue;</span><br><span class="line"><span class="css">				<span class="comment">/* 下面是将子盒子居中的语法 */</span></span></span><br><span class="line"><span class="css">				<span class="comment">/* display: flex; */</span></span></span><br><span class="line"><span class="css">				<span class="comment">/* justify-content: center; */</span></span></span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line"><span class="css">			<span class="selector-class">.father</span> &#123;</span></span><br><span class="line">				width: 400px;</span><br><span class="line">				height: 400px;</span><br><span class="line"><span class="css">				<span class="selector-tag">border</span>: <span class="selector-tag">solid</span> 1<span class="selector-tag">px</span> <span class="selector-id">#ddd</span>;</span></span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line"><span class="css">			<span class="selector-class">.main</span> &#123;</span></span><br><span class="line">				width: 100px;</span><br><span class="line">				height: 100px;</span><br><span class="line"><span class="css">				<span class="selector-tag">background</span>: <span class="selector-id">#7FFF00</span>;</span></span><br><span class="line">				animation-name: animation1,animation2;</span><br><span class="line"><span class="css">				<span class="comment">/* 使用两个动画名 */</span></span></span><br><span class="line">				animation-duration: 4s,4s;</span><br><span class="line"><span class="css">				<span class="comment">/* 分别指定动画时间 */</span></span></span><br><span class="line">				animation-timing-function: linear;</span><br><span class="line">				animation-iteration-count: infinite;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line"><span class="css">			<span class="keyword">@keyframes</span> animation1 &#123;</span></span><br><span class="line">				25% &#123;</span><br><span class="line">					transform: translateX(300px);</span><br><span class="line">				&#125;</span><br><span class="line"></span><br><span class="line">				25%,</span><br><span class="line">				75% &#123;</span><br><span class="line"><span class="css">					<span class="comment">/* 这一句同时应用在了两个地方！ */</span></span></span><br><span class="line">					border-radius: 50%;</span><br><span class="line">				&#125;</span><br><span class="line"></span><br><span class="line">				50% &#123;</span><br><span class="line">					transform: translate(300px, 300px);</span><br><span class="line">					border-radius: 0%;</span><br><span class="line">				&#125;</span><br><span class="line"></span><br><span class="line">				75% &#123;</span><br><span class="line">					transform: translateY(300px);</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line"><span class="css">			<span class="keyword">@keyframes</span> animation2 &#123;</span></span><br><span class="line">				25% &#123;</span><br><span class="line">					background: green;</span><br><span class="line">				&#125;</span><br><span class="line"></span><br><span class="line">				50% &#123;</span><br><span class="line">					background: blue;</span><br><span class="line">				&#125;</span><br><span class="line"></span><br><span class="line">				75% &#123;</span><br><span class="line">					background: red;</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">		<span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"father"</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"main"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h3 id="属性的重叠"><a href="#属性的重叠" class="headerlink" title="属性的重叠"></a>属性的重叠</h3><p>如果属性设置重复且属性值不同的话，，在animation-name中的位置越靠后，优先级越高。</p>
<p>如果帧数不同的话，会存在权力交接。</p>
<h3 id="多动画控制移动端引导背景页"><a href="#多动画控制移动端引导背景页" class="headerlink" title="多动画控制移动端引导背景页"></a>多动画控制移动端引导背景页</h3><p>认识了新的单位，vw与vh，</p>
<p>将宽度，高度分为100块，写多少就是占用了多少块，相对的单位，方便适配与调整。</p>
<h3 id="动画属性中间值讲解"><a href="#动画属性中间值讲解" class="headerlink" title="动画属性中间值讲解"></a>动画属性中间值讲解</h3><p> 有点抽象，存在中间的值，</p>
<p>数字型可以，可以查数100-1000</p>
<p>样式不大可以，目前不行，不能从单线逐步变为实线，也不能从单线变为点线。</p>
<h3 id="动画执行的次数"><a href="#动画执行的次数" class="headerlink" title="动画执行的次数"></a>动画执行的次数</h3><p>animation-iteration-count：infinite无限循环、数字为循环次数。</p>
<p>不要忘记还要-count</p>
<p><strong>参数可以与引入的动画名字数目对应</strong>。</p>
<h3 id="跳动的心案例"><a href="#跳动的心案例" class="headerlink" title="跳动的心案例"></a>跳动的心案例</h3><p>一个张方形的相邻两个端点是两个圆的圆心，圆的半径大于一半边长但小于边长。画图旋转便成了一个心。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="meta-keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"utf-8"</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">title</span>&gt;</span><span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">style</span> <span class="attr">type</span>=<span class="string">"text/css"</span>&gt;</span></span><br><span class="line">			body &#123;</span><br><span class="line">				height: 500px;</span><br><span class="line"><span class="css">				<span class="selector-tag">border</span>: <span class="selector-id">#000000</span> 1<span class="selector-tag">px</span> <span class="selector-tag">solid</span>;</span></span><br><span class="line"><span class="css">				<span class="comment">/* background-color: #0000FF; */</span></span></span><br><span class="line">				display: flex;</span><br><span class="line">				justify-content: center;</span><br><span class="line">				align-items: center;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line"><span class="css">			<span class="selector-class">.heart</span> &#123;</span></span><br><span class="line">				width: 200px;</span><br><span class="line">				height: 200px;</span><br><span class="line"><span class="css">				<span class="selector-tag">background</span>: <span class="selector-id">#e74c3c</span>;</span></span><br><span class="line"></span><br><span class="line"><span class="css">				<span class="comment">/* 看来这些变换函数只能写在一行，意思是同时执行 */</span></span></span><br><span class="line"><span class="css">				<span class="selector-tag">transform</span>: <span class="selector-tag">rotate</span>(45<span class="selector-tag">deg</span>) <span class="selector-tag">scale</span>(<span class="selector-class">.5</span>);</span></span><br><span class="line"></span><br><span class="line"><span class="css">				<span class="comment">/* 初始与准备，先写好状态 */</span></span></span><br><span class="line"><span class="css">				<span class="selector-tag">opacity</span>: <span class="selector-class">.5</span>;</span></span><br><span class="line">				animation-name: hd;</span><br><span class="line">				animation-duration: 2s;</span><br><span class="line">				animation-iteration-count: infinite;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line"><span class="css">			<span class="keyword">@keyframes</span> hd &#123;</span></span><br><span class="line">				25% &#123;</span><br><span class="line">					opacity: 1;</span><br><span class="line">					transform: rotate(45deg) scale(1);</span><br><span class="line">				&#125;</span><br><span class="line"></span><br><span class="line">				50% &#123;</span><br><span class="line"><span class="css">					<span class="selector-tag">opacity</span>: <span class="selector-class">.5</span>;</span></span><br><span class="line"><span class="css">					<span class="selector-tag">transform</span>: <span class="selector-tag">rotate</span>(45<span class="selector-tag">deg</span>) <span class="selector-tag">scale</span>(<span class="selector-class">.5</span>);</span></span><br><span class="line">				&#125;</span><br><span class="line"></span><br><span class="line">				75% &#123;</span><br><span class="line">					opacity: 1;</span><br><span class="line">					transform: rotate(45deg) scale(1);</span><br><span class="line">				&#125;</span><br><span class="line"></span><br><span class="line">				85% &#123;</span><br><span class="line"><span class="css">					<span class="selector-tag">opacity</span>: <span class="selector-class">.5</span>;</span></span><br><span class="line"><span class="css">					<span class="selector-tag">transform</span>: <span class="selector-tag">rotate</span>(45<span class="selector-tag">deg</span>) <span class="selector-tag">scale</span>(<span class="selector-class">.5</span>);</span></span><br><span class="line"></span><br><span class="line">				&#125;</span><br><span class="line"></span><br><span class="line">				90% &#123;</span><br><span class="line">					/* 每次都舍弃了之前设定的值，</span><br><span class="line">					并不会在旋转45度的基础上执行其他的动作</span><br><span class="line">					 所以我们的每次动作都当做他是没有旋转的*/</span><br><span class="line">					opacity: 1;</span><br><span class="line">					transform: rotate(45deg) scale(1);</span><br><span class="line">				&#125;</span><br><span class="line">				100%&#123;</span><br><span class="line"><span class="css">					<span class="selector-tag">opacity</span>: <span class="selector-class">.5</span>;</span></span><br><span class="line"><span class="css">					<span class="selector-tag">transform</span>: <span class="selector-tag">rotate</span>(45<span class="selector-tag">deg</span>) <span class="selector-tag">scale</span>(<span class="selector-class">.5</span>);</span></span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line"><span class="css">			<span class="selector-class">.heart</span><span class="selector-pseudo">::before</span> &#123;</span></span><br><span class="line">				content: '';</span><br><span class="line"><span class="css">				<span class="comment">/* 指定要在元素之前或之后插入的生成内容。 */</span></span></span><br><span class="line"></span><br><span class="line">				width: 200px;</span><br><span class="line">				height: 200px;</span><br><span class="line">				border-radius: 50%;</span><br><span class="line">				position: absolute;</span><br><span class="line"><span class="css">				<span class="selector-tag">background</span>: <span class="selector-id">#e74c3c</span>;</span></span><br><span class="line"></span><br><span class="line"><span class="css">				<span class="comment">/* 开始移动 */</span></span></span><br><span class="line">				transform: translateX(-100px);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line"><span class="css">			<span class="selector-class">.heart</span><span class="selector-pseudo">::after</span> &#123;</span></span><br><span class="line">				content: '';</span><br><span class="line"><span class="css">				<span class="comment">/* 指定要在元素之前或之后插入的生成内容。 */</span></span></span><br><span class="line"></span><br><span class="line">				width: 200px;</span><br><span class="line">				height: 200px;</span><br><span class="line">				border-radius: 50%;</span><br><span class="line">				position: absolute;</span><br><span class="line"><span class="css">				<span class="selector-tag">background</span>: <span class="selector-id">#e74c3c</span>;</span></span><br><span class="line">				transform: translateY(-100px);</span><br><span class="line">			&#125;</span><br><span class="line">		<span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"heart"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>该看第13个了，把视频和笔记跟着完成。</p>
<p>步进，渐变，方向</p>

        </div>

        <blockquote class="post-copyright">
    
    <div class="content">
        
<span class="post-time">
    Last updated: <time datetime="2020-10-04T09:05:41.699Z" itemprop="dateUpdated">2020-10-04 17:05:41</time>
</span><br>


        
        这里可以写作者留言，标签和 hexo 中所有变量及辅助函数等均可调用，示例：<a href="/blog/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/" target="_blank" rel="external">https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/</a>
        
    </div>
    
    <footer>
        <a href="https://gitee.com/songbug/blog.git">
            <img src="/blog/img/avatar.jpg" alt="Song Wani">
            Song Wani
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            

            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/&title=《CSS_Animation进阶》 — SongKaBaKa&pic=https://gitee.com/songbug/blog.git/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/&title=《CSS_Animation进阶》 — SongKaBaKa&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《CSS_Animation进阶》 — SongKaBaKa&url=https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/&via=https://gitee.com/songbug/blog.git" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/blog/2020/09/27/CSS3%E7%9A%84%E5%86%8D%E5%AD%A6%E4%B9%A0/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">CSS3的再学习</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/blog/2020/09/23/CSS3%E7%9A%84%E5%AD%A6%E4%B9%A0/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">CSS3的学习</h4>
      </a>
    </div>
  
</nav>



    




















</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        谢谢大爷~
        <i class="icon icon-quote-right"></i>
    </h3>
    <div class="reward-content">
        
        <div class="reward-code">
            <img id="rewardCode" src="/blog/img/wechat.jpg" alt="打赏二维码">
        </div>
        
        <label class="reward-toggle">
            <input id="rewardToggle" type="checkbox" class="reward-toggle-check"
                data-wechat="/blog/img/wechat.jpg" data-alipay="/blog/img/alipay.jpg">
            <div class="reward-toggle-ctrol">
                <span class="reward-toggle-item wechat">微信</span>
                <span class="reward-toggle-label"></span>
                <span class="reward-toggle-item alipay">支付宝</span>
            </div>
        </label>
        
    </div>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
            <span>This blog is licensed under a <a rel="license noopener" href="https://creativecommons.org/licenses/by/4.0/" target="_blank">Creative Commons Attribution 4.0 International License</a>.</span>
        </p>
    </div>
    <div class="bottom">
        <p><span>Song Wani &copy; 2019 - 2021</span>
            <span>
                
                Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
            </span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/&title=《CSS_Animation进阶》 — SongKaBaKa&pic=https://gitee.com/songbug/blog.git/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/&title=《CSS_Animation进阶》 — SongKaBaKa&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《CSS_Animation进阶》 — SongKaBaKa&url=https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/&via=https://gitee.com/songbug/blog.git" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="//api.qrserver.com/v1/create-qr-code/?data=https://gitee.com/songbug/blog.git/2020/09/26/CSS_Animation%E8%BF%9B%E9%98%B6/" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/blog/', SHARE: true, REWARD: true };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = '死鬼去哪里了！';
            clearTimeout(titleTime);
        } else {
            document.title = '(つェ⊂)咦!又好了!';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



</body>
</html>
